import 'package:aitao_flutter/const/common_const.dart';
import 'package:aitao_flutter/mine/controller/relation_page_controller.dart';
import 'package:aitao_flutter/mine/views/fans_page.dart';
import 'package:aitao_flutter/mine/views/focus_page.dart';
import 'package:aitao_flutter/mine/views/friends_page.dart';
import 'package:aitao_flutter/mine/views/seeme_page.dart';
import 'package:aitao_flutter/style/color_style.dart';
import 'package:aitao_flutter/style/text_style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class RelationPage extends StatefulWidget {
  RelationPage({super.key});
  final RelationController controller = Get.put(RelationController());
  @override
  State<RelationPage> createState() => _RelationPageState();
}

class _RelationPageState extends State<RelationPage>
    with SingleTickerProviderStateMixin {
  late TabController tabController;
  @override
  Widget build(BuildContext context) {
    return GetBuilder<RelationController>(builder: ((controller) {
      return SafeArea(
          child: Scaffold(
        backgroundColor: ColorStyle.backGroundColor,
        body: Column(children: [
          Container(
            padding: const EdgeInsets.fromLTRB(14, 0, 14, 0),
            height: 44.h,
            color: ColorStyle.backGroundColor,
            child:
                Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
              GestureDetector(
                child: const Icon(Icons.arrow_back_ios_new_rounded),
                onTap: () {
                  Get.back();
                },
              ),
              Expanded(
                  child: Container(
                alignment: Alignment.center,
                color: ColorStyle.backGroundColor,
                child: TabBar(
                  isScrollable: true,
                  unselectedLabelStyle: const TextStyle(
                      color: ColorStyle.ashGreyColor, fontSize: 15),
                  labelColor: ColorStyle.normalTextColor,
                  indicatorColor: ColorStyle.themeColor,
                  indicatorSize: TabBarIndicatorSize.label,
                  indicatorPadding: const EdgeInsets.only(left: 8, right: 8),
                  indicatorWeight: 3,
                  labelPadding: const EdgeInsets.only(bottom: 5),
                  labelStyle: Styles.boldText_16,
                  tabs: const [
                    Padding(
                        padding: EdgeInsets.only(left: 8, right: 8),
                        child: Text(MineStringConst.focusText)),
                    Padding(
                        padding: EdgeInsets.only(left: 8, right: 8),
                        child: Text(MineStringConst.fansText)),
                    Padding(
                        padding: EdgeInsets.only(left: 8, right: 8),
                        child: Text(MineStringConst.friendText)),
                    Padding(
                        padding: EdgeInsets.only(left: 8, right: 8),
                        child: Text(MineStringConst.seeMeText))
                  ],
                  controller: tabController,
                ),
              )),
              const Icon(
                Icons.arrow_back_ios_new_rounded,
                color: ColorStyle.backGroundColor,
              )
            ]),
          ),
          Expanded(
              child: TabBarView(
            controller: tabController,
            children: const [
              FocusPage(),
              FansPage(),
              FriendsPage(),
              SeeMePage(),
            ],
          ))
        ]),
      ));
    }));
  }

  @override
  void initState() {
    super.initState();
    tabController = TabController(
        length: 4, vsync: this, initialIndex: widget.controller.index);
  }
}
